package com.example.happybirthday

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Email
import androidx.compose.material.icons.filled.Phone
import androidx.compose.material.icons.filled.Share
import androidx.compose.material.icons.filled.Star
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MaterialTheme {
                PinkBarbieBusinessCard()
            }
        }
    }
}

@Composable
fun PinkBarbieBusinessCard() {
    Box(
        modifier = Modifier.fillMaxSize()
    ) {
        // 背景图片
        Image(
            painter = painterResource(id = R.drawable.background),
            contentDescription = "背景",
            modifier = Modifier.fillMaxSize(),
            contentScale = ContentScale.Crop
        )

        // 粉色渐变遮罩（保持图片但添加粉色滤镜）
        Box(
            modifier = Modifier
                .fillMaxSize()
                .background(
                    brush = Brush.verticalGradient(
                        colors = listOf(
                            Color(0x99FFB6C1), // 浅粉色半透明
                            Color(0x99FF69B4), // 热粉色半透明
                            Color(0x99DB7093)  // 深粉色半透明
                        )
                    )
                )
        )

        // 装饰元素
        PinkDecorations()

        // 主要内容
        Column(
            modifier = Modifier
                .fillMaxSize()
                .padding(24.dp),
            verticalArrangement = Arrangement.SpaceBetween
        ) {
            // 顶部装饰
            Row(
                modifier = Modifier.fillMaxWidth(),
                horizontalArrangement = Arrangement.SpaceEvenly
            ) {
                DecorativeHeart("💖")
                DecorativeHeart("🌸")
                DecorativeHeart("🎀")
            }

            // 中间内容
            Column(
                modifier = Modifier.fillMaxWidth(),
                horizontalAlignment = Alignment.CenterHorizontally
            ) {
                // 公主头像框
                Box(
                    modifier = Modifier
                        .size(150.dp)
                        .shadow(
                            elevation = 20.dp,
                            shape = CircleShape,
                            clip = true
                        )
                        .background(
                            brush = Brush.radialGradient(
                                colors = listOf(
                                    Color(0xFFFFD700), // 金色
                                    Color(0xFFFF69B4)  // 粉色
                                )
                            ),
                            shape = CircleShape
                        )
                        .padding(10.dp)
                ) {
                    Box(
                        modifier = Modifier
                            .fillMaxSize()
                            .background(Color.White, CircleShape)
                            .padding(8.dp)
                    ) {
                        Image(
                            painter = painterResource(id = R.drawable.androidparty),
                            contentDescription = "公主头像",
                            modifier = Modifier
                                .fillMaxSize()
                                .clip(CircleShape),
                            contentScale = ContentScale.Crop
                        )
                    }
                }

                Spacer(modifier = Modifier.height(32.dp))

                // 姓名 - 超大粉嫩字体
                Text(
                    text = "陈柔轩",
                    fontSize = 52.sp,
                    fontWeight = FontWeight.Bold,
                    color = Color.White,
                    modifier = Modifier.padding(bottom = 8.dp),
                    textAlign = TextAlign.Center,
                    letterSpacing = 3.sp
                )

                // 职位 - 带装饰
                Text(
                    text = "💕 Android开发者 💕",
                    fontSize = 22.sp,
                    fontWeight = FontWeight.SemiBold,
                    color = Color(0xFFFFFACD), // 柠檬绸色
                    modifier = Modifier.padding(bottom = 8.dp),
                    textAlign = TextAlign.Center
                )

                // 副标题
                Text(
                    text = "梦想与代码的魔法师",
                    fontSize = 16.sp,
                    fontWeight = FontWeight.Medium,
                    color = Color(0xFFFFF8DC), // 玉米丝色
                    textAlign = TextAlign.Center
                )
            }

            // 底部联系信息卡片
            Surface(
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(horizontal = 16.dp),
                shape = RoundedCornerShape(35.dp),
                color = Color(0xF5FFFFFF), // 半透明白色
                shadowElevation = 12.dp
            ) {
                Column(
                    modifier = Modifier.padding(32.dp),
                    horizontalAlignment = Alignment.Start
                ) {
                    PinkContactRow(
                        icon = Icons.Filled.Phone,
                        text = "186 1138 0000",
                        iconColor = Color(0xFFFF1493) // 深粉色
                    )

                    Spacer(modifier = Modifier.height(20.dp))

                    PinkContactRow(
                        icon = Icons.Filled.Share,
                        text = "@BarbieDeveloper",
                        iconColor = Color(0xFFDA70D6) // 兰花色
                    )

                    Spacer(modifier = Modifier.height(20.dp))

                    PinkContactRow(
                        icon = Icons.Filled.Email,
                        text = "princess@barbie.com",
                        iconColor = Color(0xFFFF69B4) // 热粉色
                    )
                }
            }

            // 底部装饰
            Text(
                text = "✨ Barbie的魔法世界 ✨",
                fontSize = 14.sp,
                color = Color.White,
                fontWeight = FontWeight.Medium,
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(vertical = 16.dp),
                textAlign = TextAlign.Center
            )
        }
    }
}

@Composable
fun PinkContactRow(icon: androidx.compose.ui.graphics.vector.ImageVector, text: String, iconColor: Color) {
    Row(
        modifier = Modifier.fillMaxWidth(),
        verticalAlignment = Alignment.CenterVertically
    ) {
        Icon(
            imageVector = icon,
            contentDescription = null,
            modifier = Modifier
                .size(36.dp) // 放大图标
                .padding(end = 24.dp),
            tint = iconColor
        )
        Text(
            text = text,
            fontSize = 18.sp,
            color = Color(0xFF8B008B), // 深洋红色
            fontWeight = FontWeight.SemiBold,
            letterSpacing = 1.sp
        )
    }
}

@Composable
fun PinkDecorations() {
    Box(modifier = Modifier.fillMaxSize()) {
        // 左上角星星
        Icon(
            imageVector = Icons.Filled.Star,
            contentDescription = null,
            tint = Color(0x99FFD700), // 金色
            modifier = Modifier
                .size(45.dp)
                .align(Alignment.TopStart)
                .padding(40.dp)
                .rotate(25f)
        )

        // 右上角星星
        Icon(
            imageVector = Icons.Filled.Star,
            contentDescription = null,
            tint = Color(0x99FFFFFF), // 白色
            modifier = Modifier
                .size(35.dp)
                .align(Alignment.TopEnd)
                .padding(35.dp)
                .rotate(-15f)
        )

        // 左下角爱心
        Text(
            text = "💗",
            fontSize = 30.sp,
            modifier = Modifier
                .align(Alignment.BottomStart)
                .padding(30.dp)
        )

        // 右下角爱心
        Text(
            text = "💝",
            fontSize = 28.sp,
            modifier = Modifier
                .align(Alignment.BottomEnd)
                .padding(32.dp)
        )
    }
}

@Composable
fun DecorativeHeart(emoji: String) {
    Box(
        modifier = Modifier
            .size(50.dp)
            .background(Color.White.copy(alpha = 0.3f), CircleShape)
            .padding(8.dp),
        contentAlignment = Alignment.Center
    ) {
        Text(
            text = emoji,
            fontSize = 20.sp
        )
    }
}

@Preview(showBackground = true)
@Composable
fun PreviewPinkBarbieBusinessCard() {
    MaterialTheme {
        PinkBarbieBusinessCard()
    }
}